!function(window){

    "use strict";

    window.com = {};

    (function(){

        this.device = function(){
            var bom1 = navigator.userAgent,send = {};
            if(bom1.match(/iPhone|iPad/i)){
                send.version = Number(bom1.match(/OS\s([5-9])_/)[1]);
                send.name = bom1.match(/(iPhone|iPad)/i)[1];
            }else if(bom1.match(/Android/i)){
                send.version = Number(bom1.match(/Android\s(\d\.\d)/)[1]);
                send.name = 'Android';
            }else if(bom1.match(/Firefox|Chrome/i)){
                send.version = Number(bom1.match(/(Firefox|Chrome)\/(\d+)\./)[2]);
                send.name = bom1.match(/Firefox|Chrome/i)[0];
            }else if(bom1.match(/MSIE/)){
                send.version = Number(bom1.match(/MSIE\s(\d+)\./)[1]);
                send.name = 'ie';
            }
            return send;
        };

        this.supportCss3 = function(attr){
            var box = ['-webkit-','-os-','-ms-','-moz-'];
            var defaultStyle = document.documentElement.style;
            if(attr in defaultStyle){
                return true;
            }else{
                for(var i=0;i<box.length;i++){
                    if(box[i]+attr in defaultStyle){
                        return true;
                    }
                }
            }
            return false;
        };

        this.page = function(){
            var str = '<div id="nav">'+
                '<ul class="nav-item"> ' +
                '<li data-name="index" class="nav-list"> <img src="/img/fixed/index-white.png" alt=""><span>主页</span></li>' +
                '<li data-name="say" class="nav-list"><img src="/img/fixed/say-white.png" alt=""><span>说说</span></li> ' +
                '<li data-name="article" class="nav-list"><img src="/img/fixed/article-white.png" alt=""><span>文章</span> </li> ' +
                '<li data-name="movie" class="nav-list"><img src="/img/fixed/movie-white.png" alt=""> <span>影视</span></li> ' +
                '<li data-name="photo" class="nav-list"> <img src="/img/fixed/photo-white.png" alt=""><span>照片</span></li> ' +
                '<li data-name="message" class="nav-list"> <img src="/img/fixed/message-white.png" alt=""><span>留言</span></li> ' +
                '</ul> ' +
                '</div>';
            var tmp = $(str);
            var id = $("meta[data-name]").attr("data-name");
                tmp.find("[data-name='"+id+"']").find('img').prop('src','/img/fixed/'+id+'.png');
            var foot = '<footer><p>Copyright &copy;http://www.featsky.com</p><p>Email 641151096qq.com</p></footer>';
            $('body').append(foot).append(tmp);
        };

        this.moveDetail = function(obj,fun){
            obj.find('.back').on('tap',function(){
                obj.css('-webkit-transform','translateX(0%)');
                fun && fun();
            })
        };

        this.navEffect = function(){
            var nav = $("#nav");
            $('.menu-list').on('tap',function(){
                var box = window.getComputedStyle(nav[0],null)['webkitTransform'];
                box = box.split(',');
                if(box == 'none'||0 == $.trim(box[4])){
                    nav.css('-webkit-transform','translateX(-100%)');
                }else{
                    nav.css('-webkit-transform','translateX(0%)');
                }
            });

            nav.find('.nav-list').on('tap',function(){
                var name = $(this).attr('data-name');
                window.open(name+".html","_self");
            })
        };

    }).apply(com);

    $(function(){
        if(!/article_detail/g.test(document.URL)){
            history.pushState(null, null, document.URL);
            window.addEventListener('popstate', function () {
                history.pushState(null, null, document.URL);
            });
        }

        com.device();
        com.page();
        com.navEffect();
    })

}(window);









